<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<title>APP</title>
		<link rel="stylesheet" type="text/css" href="../css/aui.css" />
	</head>
	<style>
		.my-header {
			background: url('../image/mybg.png') no-repeat;
			background-size: cover;
			min-height: 160px;
			position: relative;
		}
		.my-info {
			position: relative;
			padding: 20px 0;
			width: 100%;
			bottom: 0;
			text-align: center;
			vertical-align: center;
		}
		.my-info img {
			width: 80px;
			height: 80px;
			border-radius: 50%;
		}
		.my-info p.username {
			margin-top: 95px;
			color: #ffffff;
			font-size: 18px;
		}
		.my-menu {
			position: absolute;
			width: 100%;
			height: 45px;
			line-height: 45px;
			left: 0;
			bottom: 0;
			text-align: center;
			background: #ffffff;
			filter: Alpha(opacity=50);
			background: rgba(255, 255, 255, 0.2) none repeat scroll 0 0 !important;
			color: #ffffff;
			font-size: 14px;
		}
		.my-menu .aui-col-xs-3 {
			border-right: 1px solid #9bd6d5;
		}
		.my-menu .aui-col-xs-3:last-child {
			border-right: none;
		}
		.my-menu > div:active {
			background: #ffffff;
			filter: Alpha(opacity=50);
			background: rgba(255, 255, 255, 0.2) none repeat scroll 0 0 !important;
		}
		.aui-list-view-cell {
			line-height: 26px;
		}
	</style>
	<body>
		<!--    <div class="aui-content my-header">
		<div class="my-info">
		<!--<img id="" src="../image/demo5.png">-->
		<!--            <p class="username">天天</p>
		</div>-->
		<!--        <div class="my-menu">
		<div class="aui-col-xs-3">首页</div>
		<div class="aui-col-xs-3">动态</div>
		<div class="aui-col-xs-3">关注</div>
		<div class="aui-col-xs-3">设置</div>
		</div>-->
		<!--</div>-->
		<div class="aui-content aui-card"></div>
		<div class="aui-content aui-card">
			<ul class="aui-list-view">
				<li class="aui-list-view-cell" tapmode onclick="LoginOut()">
					<a class="aui-arrow-right">切换账户</a>
				</li>
				<li class="aui-list-view-cell" tapmode="" onclick="OpenList(1)">
					<a class="aui-arrow-right">我的签名</a>
				</li>
				<li class="aui-list-view-cell" tapmode="" onclick="OpenList(2)">
					<a class="aui-arrow-right">签名模板</a>
				</li>
				<li class="aui-list-view-cell" tapmode="" onclick="OpenSignParam()">
					<a class="aui-arrow-right">手写板配置</a>
				</li>
				<li class="aui-list-view-cell" onclick="OpenHelp()" tapmode="">
					<a class="aui-arrow-right">使用指南</a>
				</li>
			</ul>
		</div>
		<div class="aui-content aui-card">
			<ul class="aui-list-view">
				<li class="aui-list-view-cell" tapmode onclick="checkUpdate()">
					<a class="aui-arrow-right">检查更新</a>
				</li>
				<li class="aui-list-view-cell">
					<a class="aui-arrow-right" tapmode="" onclick="ClearCache()">清除缓存 <span class="aui-badge aui-badge-danger" id="cache">36M</span> </a>
				</li>
<!--				<li class="aui-list-view-cell aui-switch-body">
					<div class="aui-switch-title">
						声音提醒
					</div>
					<input type="checkbox" class="aui-switch aui-pull-right" checked>
				</li>
				<li class="aui-list-view-cell aui-switch-body">
					<div class="aui-switch-title">
						自动更新
					</div>
					<input type="checkbox" class="aui-switch aui-pull-right">
				</li>-->
				<li class="aui-list-view-cell" onclick="OpenContact()" tapmode="">
					<a class="aui-arrow-right">联系我们</a>
				</li>
				<li class="aui-list-view-cell" tapmode onclick="api.closeWidget()">
					<a class="aui-arrow-right">退出系统</a>
				</li>
			</ul>
		</div>
	</body>
	<script type="text/javascript" src="../script/api.js" ></script>
	<script type="text/javascript">
		var uid = null;
		function LoginOut() {
			api.removePrefs({
				key : 'userinfo'
			}, function(ret, err) {
				api.sendEvent({
					name : 'loginOut_Event',
				});
				api.openWin({
					name : 'Login_win',
					url : 'login_win.html'
				});
			});
		}

		function OpenHelp() {
			api.openWin({
				name : 'help',
				url : 'help_win.html',
				vScrollBarEnabled : false,
				delay : 200
			});
		}

		function OpenContact() {
			alert("联系我们");
		}

		function OpenSignParam() {
			api.openWin({
				name : 'setSign_win',
				url : 'setSign_win.html',
				vScrollBarEnabled : false,
				delay : 200
			});
		}

		function ClearCache() {
			api.clearCache(function(ret, err) {
				api.toast({
					msg : '清除成功',
					location : 'middle'
				});
				GetCache();
			});
		}

		function checkUpdate() {
			var mam = api.require('mam');
			mam.checkUpdate(function(ret, err) {
				if (ret) {
					var result = ret.result||{};
					if (result.status) {
						//var str = '操作成功状态值:' + ret.status + ';是否有更新:' + result.update + ';设备上当前版本是否被强行关闭:' + result.closed + ';新版本型号:' + result.version + ';更新描述:' + result.versionDes + ';强行关闭提示语:' + result.closeTip + ';更新提示语:' + result.updateTip + ';下载地址:' + result.source + ';发布时间:' + result.time;
						var str = ';新版本型号:' + result.version + '\r\n更新描述:' + result.versionDes + '\r\n发布时间:' + result.time;
						api.alert({
							msg : str
						});							
					}
					else {
						api.alert({
							msg : '已是最新版本!'
						});
					}
				} else {
					api.alert({
						msg : '访问错误!'
					});
				}
			});
		}

		function GetCache() {
			api.getCacheSize(function(ret, err) {
				var size = parseInt(ret.size);
				var str = "";
				if (size > 0) {
					size /= 1024;
					if (size < 1000) {
						str = size.toFixed(0) + 'KB';
					} else {
						size /= 1024;
						str = size.toFixed(0) + 'M';
					}
				}
				var el = $api.byId('cache');
				$api.text(el, str);
			});
		}

		function OpenList(idx) {
			api.openWin({
				name : 'siglist',
				url : 'siglist_win.html',
				vScrollBarEnabled : false
			});
			//			setTimeout(
			//			api.execScript({
			//				name:'siglist1',
			//	            script: 'ChangeData(1);'
			//          })
			//          ,2500);
		}

		apiready = function() {
			var param = {};
			var uid = $api.getStorage('uid');
			if (uid) {
				api.readFile({
					path : 'fs://' + uid + '.param.json'
				}, function(ret, err) {
					if (ret.data) {
						param = JSON.parse(ret.data);
					} else {
					}
				});
			} else {
				var lineStyle = {
					width : 1,
					color : "#5adf20", //绿色
					kind : 0,
					mode : "round",
					isShow : true
				};
				var gridStyle = {
					width : 0.5,
					background : '#000',
					color : "#ddd",
					mode : "round",
					isShow : true,
					sw : 20,
					sh : 20
				};
				var pointStyle = {
					r : 2,
					color : "#5ad120",
					isShow : true,
					isInterpolation : true
				};
				param.lineStyle = lineStyle;
				param.gridStyle = gridStyle;
				param.pointStyle = pointStyle;
				api.writeFile({
					path : 'fs://' + uid + '.param.json',
					data : JSON.stringify(param)
				}, function(ret, err) {
					//coding...
				});
				$api.setStorage('param', param);
			}
			GetCache();
		}
	</script>
</html>